package com.ruoyi.system.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.ByMyStandardMapper;
import com.ruoyi.system.domain.ByMyStandard;
import com.ruoyi.system.service.IByMyStandardService;

/**
 * MyStandardService业务层处理
 * 
 * @author ruoyi
 * @date 2024-04-19
 */
@Service
public class ByMyStandardServiceImpl implements IByMyStandardService 
{
    @Autowired
    private ByMyStandardMapper byMyStandardMapper;

    /**
     * 查询MyStandard
     * 
     * @param id MyStandard主键
     * @return MyStandard
     */
    @Override
    public ByMyStandard selectByMyStandardById(String id)
    {
        return byMyStandardMapper.selectByMyStandardById(id);
    }

    /**
     * 查询MyStandard列表
     * 
     * @param byMyStandard MyStandard
     * @return MyStandard
     */
    @Override
    public List<ByMyStandard> selectByMyStandardList(ByMyStandard byMyStandard)
    {
        byMyStandard.setUserId(SecurityUtils.getUserId());
        return byMyStandardMapper.selectByMyStandardList(byMyStandard);
    }

    /**
     * 新增MyStandard
     * 
     * @param byMyStandard MyStandard
     * @return 结果
     */
    @Override
    public int insertByMyStandard(ByMyStandard byMyStandard)
    {
        byMyStandard.setCreateTime(DateUtils.getNowDate());
        return byMyStandardMapper.insertByMyStandard(byMyStandard);
    }

    /**
     * 修改MyStandard
     * 
     * @param byMyStandard MyStandard
     * @return 结果
     */
    @Override
    public int updateByMyStandard(ByMyStandard byMyStandard)
    {
        return byMyStandardMapper.updateByMyStandard(byMyStandard);
    }

    /**
     * 批量删除MyStandard
     * 
     * @param ids 需要删除的MyStandard主键
     * @return 结果
     */
    @Override
    public int deleteByMyStandardByIds(String[] ids)
    {
        return byMyStandardMapper.deleteByMyStandardByIds(ids);
    }

    /**
     * 删除MyStandard信息
     * 
     * @param id MyStandard主键
     * @return 结果
     */
    @Override
    public int deleteByMyStandardById(String id)
    {
        return byMyStandardMapper.deleteByMyStandardById(id);
    }

    @Override
    public boolean judgeIsBuy(String standardId) {

        ByMyStandard byMyStandard = new ByMyStandard();
        byMyStandard.setStandardId(standardId);
        byMyStandard.setUserId(SecurityUtils.getUserId());
        List<ByMyStandard> list = byMyStandardMapper.selectByMyStandardList(byMyStandard);
        if(list.size()>0){
            return true;
        }
        return false;
    }
}
